package projectManagement;

import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class NewAnnouncementUI extends JPanel implements ActionListener{
	private JTextField titleText;

	JFrame f;
	
	public NewAnnouncementUI() {
		setPreferredSize(new Dimension(449, 348));
		setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 114, 429, 189);
		add(scrollPane);
		
		JTextArea msgText = new JTextArea();
		scrollPane.setViewportView(msgText);
		
		JButton btnPost = new JButton("POST");
		btnPost.setBounds(251, 306, 89, 31);
		add(btnPost);
		
		JButton btnCancel = new JButton("CANCEL");
		btnCancel.setBounds(350, 306, 89, 31);
		add(btnCancel);
		
		JLabel lblMessage = new JLabel("Message:");
		lblMessage.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblMessage.setBounds(10, 90, 75, 21);
		add(lblMessage);
		
		titleText = new JTextField();
		titleText.setBounds(10, 59, 196, 20);
		add(titleText);
		titleText.setColumns(10);
		
		JLabel lblTitle = new JLabel("Title:");
		lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblTitle.setBounds(10, 41, 46, 14);
		add(lblTitle);
		
		f = new JFrame("NEW ANNOUNCEMENT");
		f.getContentPane().add(this);
		f.pack();
		f.setLocationRelativeTo(null);
		f.setVisible(true);
		f.setResizable(true);
		f.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
		
		
	}
	
	public NewAnnouncementUI(String title, String msg) {
		setPreferredSize(new Dimension(449, 348));
		setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 114, 429, 189);
		add(scrollPane);
		
		JTextArea msgText = new JTextArea();
		msgText.setText(msg);
		scrollPane.setViewportView(msgText);
		
		JButton btnCancel = new JButton("CANCEL");
		btnCancel.setBounds(350, 306, 89, 31);
		add(btnCancel);
		
		JLabel lblMessage = new JLabel("Message:");
		lblMessage.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblMessage.setBounds(10, 90, 75, 21);
		add(lblMessage);
		
		titleText = new JTextField();
		titleText.setText(title);
		titleText.setBounds(10, 59, 196, 20);
		add(titleText);
		titleText.setColumns(10);
		
		JLabel lblTitle = new JLabel("Title:");
		lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblTitle.setBounds(10, 41, 46, 14);
		add(lblTitle);
		
		f = new JFrame("NEW ANNOUNCEMENT");
		f.getContentPane().add(this);
		f.pack();
		f.setLocationRelativeTo(null);
		f.setVisible(true);
		f.setResizable(true);
		f.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
		
		
	}

	@Override
	public void actionPerformed(ActionEvent btn) {
		String cmd = btn.getActionCommand();
		
		if(cmd.equalsIgnoreCase("POST")){
			
		}
		
		if(cmd.equalsIgnoreCase("CANCEL")){
			f.setVisible(false);
		}
		
	}
}
